<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件修饰符</title>
    <script src="./lib/vue-2.6.12.js"></script>
    <style>
        .inner {
            height: 120px;
            background-color: aqua;
        }
        .outer {
            padding: 30px;
            background-color: brown;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="inner" @click="innerHandler">
            <button @click="butHandler">戳他，事件冒泡</button>
            <button @click.stop="butHandler">戳我，阻止冒泡</button>
            <button @click.once="butHandler">戳我，设置了once事件</button>
            <hr>
            <a href="http://www.baidu.com" @click="linkclick">去百度</a>
            <a href="http://www.baidu.com" @click.prevent="linkclick">去百度(阻止默认行为)</a>
        </div>
        <hr>
        <div class="inner" @click.capture="innerHandler">
            div 设置了 capture 事件
            <button @click="butHandler">戳他，上层设置了事件捕获</button>
            <hr>
            <a href="http://www.baidu.com" @click.prevent.once="linkclick">去百度（阻止一次）</a>
        </div>
        <hr>
        <div class="outer" @click="outerHandler">
            <div class="inner" @click.self="innerHandler">
                div 设置了 self 事件
                <button @click="butHandler">戳他，上层设置了self事件</button>
            </div>
        </div>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {

            },
            methods: {
                outerHandler() {
                    console.log('这是 outer div 的点击事件')
                },
                innerHandler() {
                    console.log('这是 inner div 的点击事件')
                },
                butHandler() {
                    console.log('这是 button 的点击事件')
                },
                linkclick() {
                    console.log('点击超链接')
                }
            }
        })

    </script>
</body>

</html>